package recursive.myPow;
/**
 * @Date 2020/03/30
 * @author 王光浩
 * @Thinking 使用递归实现
 */
public class MyMethodThree {
	public double myPow(double x, int n) {
		long N=n;
		if(N<0) {
			N=-N;
			x=1/x;
		}
		return helper(x,N);
	}
	private double helper(double x,long n) {
		if(n==0)return 1;
		double value=helper(x,n/2);
		value*=value;
		if(n%2!=0)value*=x;
		return value;
	}
}
